package com.jilefojing.service;

import java.util.List;

import com.jilefojing.beans.enums.ItemTypeEnumForSource;
import com.jilefojing.beans.enums.ProgressStatusForSource;
import com.jilefojing.beans.enums.StatusEnumForPublish;
import com.jilefojing.beans.exception.UserContextException;
import com.jilefojing.beans.pojos.RCategorySource;
import com.jilefojing.beans.pojos.RTagSource;
import com.jilefojing.beans.pojos.enhanced.base.BaseEnhanced;
import com.jilefojing.beans.vo.Pagination;
import com.jilefojing.beans.vo.Source;
import com.jilefojing.context.beans.vo.UserContext;

/**
 * 资源通用服务
 * 
 * @author jiangguoshun
 * 
 */
public interface ISourceService {

	void checkSource(ItemTypeEnumForSource itemType, long itemId, UserContext userContext) throws UserContextException;

	/**
	 * 获取关联资源
	 * 
	 * @param itemType
	 *            资源类型
	 * @param id
	 *            资源id
	 * @param returnRelationTypes
	 *            返回的关联数据类型
	 * @param pagination
	 * @param userContext
	 * @return
	 */
	Pagination<? extends BaseEnhanced> getPaginationForCorrelation(ItemTypeEnumForSource itemType, long id, List<ItemTypeEnumForSource> returnRelationTypes,
			Pagination<? extends BaseEnhanced> pagination, UserContext userContext);

	/**
	 * 根据标签获取资源
	 * 
	 * @param tagIds
	 * @param returnItemTypes
	 * @param statuses
	 * @param pagination
	 * @param userContext
	 * @return
	 */
	Pagination<? extends BaseEnhanced> getPaginationByTagIds(List<Long> tagIds, List<ItemTypeEnumForSource> returnItemTypes, List<StatusEnumForPublish> statuses,
			Pagination<? extends BaseEnhanced> pagination, UserContext userContext);

	/**
	 * 根据类型获取资源 -->交集获取
	 * 
	 * @param categoryIds
	 * @param returnItemTypes
	 * @param statuses
	 * @param progressStatuses
	 * @param pagination
	 * @param userContext
	 * @return
	 */
	Pagination<? extends BaseEnhanced> getPaginationByCategoryIdsForActive(List<Long> categoryIds, List<ItemTypeEnumForSource> returnItemTypes, List<StatusEnumForPublish> statuses,
			List<ProgressStatusForSource> progressStatuses, Pagination<? extends BaseEnhanced> pagination, UserContext userContext);

	/**
	 * 根据标题关键字查询资源
	 * 
	 * @param keywords
	 * @param pagination
	 * @param userContext
	 * @return
	 */
	Pagination<Source> getPaginationByKeywordsForActive(String keywords, Pagination<Source> pagination, UserContext userContext);

	BaseEnhanced getEnhancedItem(ItemTypeEnumForSource itemType, long itemId, UserContext userContext);

	List<BaseEnhanced> getEnhancedItems(ItemTypeEnumForSource itemType, List<Long> itemIds, UserContext userContext);

	/**
	 * 不包含额外添加信息
	 * 
	 * @param itemType
	 * @param itemIds
	 * @param userContext
	 * @return
	 */
	List<BaseEnhanced> getEnhancedItemsNotAppend(ItemTypeEnumForSource itemType, List<Long> itemIds, UserContext userContext);

	BaseEnhanced appendEnhancedDCategories2EnhancedItem(BaseEnhanced enhancedItem, UserContext userContext);

	List<BaseEnhanced> appendEnhancedDCategories2EnhancedItems(List<BaseEnhanced> enhancedItems, UserContext userContext);

	BaseEnhanced appendEnhancedTags2EnhancedItem(BaseEnhanced enhancedItem, UserContext userContext);

	List<BaseEnhanced> appendEnhancedTags2EnhancedItems(List<BaseEnhanced> enhancedItems, UserContext userContext);

	BaseEnhanced appendEnhancedChildren2EnhancedItem(BaseEnhanced enhancedItem, UserContext userContext);

	List<BaseEnhanced> appendEnhancedChildren2EnhancedItems(List<BaseEnhanced> enhancedItems, UserContext userContext);

	BaseEnhanced appendEnhancedParent2EnhancedItem(BaseEnhanced enhancedItem, UserContext userContext);

	List<BaseEnhanced> appendEnhancedParent2EnhancedItems(List<BaseEnhanced> enhancedItems, UserContext userContext);

	List<RCategorySource> addDCategories(ItemTypeEnumForSource itemType, long itemId, String ckey, List<Long> categoryIds, UserContext userContext) throws UserContextException;

	List<RTagSource> addTags(ItemTypeEnumForSource itemType, long itemId, List<Long> tagIds, UserContext userContext) throws UserContextException;

}
